package com.sky.mapper.common;

import com.github.pagehelper.Page;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.pojo.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;


@Mapper
public interface CategoryMapper {

    //新增菜品分类
    @Insert("insert into category (type,name, sort, status, create_time, update_time, create_user, update_user) values (#{type},#{name}, #{sort}, #{status}, #{createTime}, #{updateTime}, #{createUser}, #{updateUser})")
    void insert(Category category);

    //菜品分页查询
    Page<Category> CategoryPage(CategoryPageQueryDTO categoryPageQueryDTO);

    //根据id删除
    @Delete("delete from category where id = #{id}")
    void deleteById(Long id);

    //修改启用禁用
    @Update("update category set status = #{status} where id = #{id}")
    void startAndStop(@Param("status") int status,@Param("id") int id);

    //修改菜品分类
    int updateCategory(Category Category);

    //根据类型查询菜品分类
    @Select("select * from category where type = #{type}")
    List<Category> findByType(Integer type);

    //查询所有分类
    @Select("select * from category")
    List<Category> findCategory();
    //查询指定分类
    List<Category> list(Integer type);
}
